<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>FreeMaker测试</title>
</head>
<body>
    <code>Map<Person>写法</code>
    ID：${person.id}<br>
    姓名${person.name}<br> <br>

    <code>遍历Map<List>写法</code>
    <#list persons as person>
        ${person}<br>
    </#list><br>


    <code>时间格式</code>
    1、日期:${cur_time?date}<br>
    2、时间:${cur_time?time}<br>
    3、日期和时间:${cur_time?datetime}<br><br>


    <code>遍历Map<Map>写法</code>
    ${mx.alingluo}<br>
    ${mx.lling}<br>
    <#list mx?keys as k>
        ${mx[k]}<br>
    </#list><br>


    <code>遍历 Map<List<Map>>写法</code>
    <#list list as m>
        ${m.id1}<br>
        ${m.id2}<br>
    </#list>
    <#list list as m>
        <#list m?keys as k>
            ${m[k]}
        </#list>
    </#list><br>


    获取当前索引<br>
    <#list persons as p>
        ${p_index}
    </#list><br>

    <p>在模板中赋值</p>
    1、数字:<br>
    <#assign x=0 />
    ${x}<br>

    2、字符串:<br>
    <#assign x="${world}" />
    ${x}<br>

    3、字符串:<br>
    <#assign x>世界太好了</#assign>
    ${x}<br>

    4、list:<br>
    <#assign x>
        <#list ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"] as n>
            ${n}<br>
        </#list>
    </#assign>
    ${x}<br>

    字符串判断（非星期一）：<br>
    <#list ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"] as n>
        <#if n != "星期一">
            ${n}<br>
        </#if>
    </#list>
    <br>

    索引判断（非星期一）：<br>
    <#list ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"] as n>
        <#if n_index != 0>
            ${n}<br>
        </#if>
    </#list>
    <br>

    索引判断（星期二或星期四）：<br>
    <#list ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"] as n>
        <#if (n_index == 1) || (n_index == 3)>
            ${n}<br>
        </#if>
    </#list>
    <br>

    if-else判断（二四为红色，其他绿色）<br>
    <#list ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"] as n>
        <#if (n_index == 1) || (n_index == 3)>
            ${n} --红色<br>
        <#else>
            ${n} --绿色<br>
        </#if>
    </#list>

    空值<br>
    ${val!}<br>

    宏定义<br>
    <#macro test foo bar="Bar" baaz=-1>
        Test text, and the params: ${foo}, ${bar}, ${baaz}
    </#macro>
    <@test foo="a" bar="b" baaz=5*5-2/><br>
    <@test foo="a" bar="b"/><br>
    <@test foo="a" baaz=5*5-2/><br>
    <@test foo="a"/><br>

    <#macro lis title items>
        <p>${title?cap_first}:
        <ul>
            <#list items as x>
                <li>${x?cap_first}
            </#list>
        </ul>
    </#macro>
    <@lis items=["mouse", "elephant", "python"] title="Animals"/>

    <#macro do_thrice>
        <#nested 1>
        <#nested 2>
        <#nested 3>
    </#macro>
    <@do_thrice ; x>
        ${x} Anything.
    </@do_thrice>

    <#macro test>
        Test text
        <#return>
        Will not be printed.
        </#macro>
    <@test/>

    内建函数：
    ${world?upper_case}<br>
    ${world?html}<br>
    ${world?upper_case?html}<br>

    ${worlds?size}<br>
    ${worlds?join(", ")}<br>
</body>
</html>